<?php

namespace app\common\dao\system\recruit;

use app\common\dao\BaseDao;
use app\common\model\system\recruit\Recruit;

class RecruitDao extends BaseDao
{

    protected function getModel(): string
    {
        return Recruit::class;
    }

    public function switchStatus($id, $data)
    {
        return ($this->getModel())::getDB()->where($this->getPk(),$id)->update($data);
    }

    public function merFieldExists($field, $value, $except = null)
    {
        return ($this->getModel())::getDB()->when($except, function ($query, $except) use ($field) {
                $query->where($field, '<>', $except);
            })->where($field, $value)->count() > 0;
    }

}
